package com.ruoyi.project.posts.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.posts.domain.LblCsDiscussPost;
import com.ruoyi.project.posts.service.ILblCsDiscussPostService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 失物招领、拼车服务、二手交易帖子Controller
 * 
 * @author BaoL
 * @date 2023-03-25
 */
@RestController
@RequestMapping("/posts/post")
public class LblCsDiscussPostController extends BaseController
{
    @Autowired
    private ILblCsDiscussPostService lblCsDiscussPostService;

    /**
     * 查询失物招领、拼车服务、二手交易帖子列表
     */
    @PreAuthorize("@ss.hasPermi('posts:post:list')")
    @GetMapping("/list")
    public TableDataInfo list(LblCsDiscussPost lblCsDiscussPost)
    {
        startPage();
        List<LblCsDiscussPost> list = lblCsDiscussPostService.selectLblCsDiscussPostList(lblCsDiscussPost);
        return getDataTable(list);
    }

    /**
     * 导出失物招领、拼车服务、二手交易帖子列表
     */
    @PreAuthorize("@ss.hasPermi('posts:post:export')")
    @Log(title = "失物招领、拼车服务、二手交易帖子", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(LblCsDiscussPost lblCsDiscussPost)
    {
        List<LblCsDiscussPost> list = lblCsDiscussPostService.selectLblCsDiscussPostList(lblCsDiscussPost);
        ExcelUtil<LblCsDiscussPost> util = new ExcelUtil<LblCsDiscussPost>(LblCsDiscussPost.class);
        return util.exportExcel(list, "post");
    }

    /**
     * 获取失物招领、拼车服务、二手交易帖子详细信息
     */
    @PreAuthorize("@ss.hasPermi('posts:post:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(lblCsDiscussPostService.selectLblCsDiscussPostById(id));
    }

    /**
     * 新增失物招领、拼车服务、二手交易帖子
     */
    @PreAuthorize("@ss.hasPermi('posts:post:add')")
    @Log(title = "失物招领、拼车服务、二手交易帖子", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LblCsDiscussPost lblCsDiscussPost)
    {
        return toAjax(lblCsDiscussPostService.insertLblCsDiscussPost(lblCsDiscussPost));
    }

    /**
     * 修改失物招领、拼车服务、二手交易帖子
     */
    @PreAuthorize("@ss.hasPermi('posts:post:edit')")
    @Log(title = "失物招领、拼车服务、二手交易帖子", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LblCsDiscussPost lblCsDiscussPost)
    {
        return toAjax(lblCsDiscussPostService.updateLblCsDiscussPost(lblCsDiscussPost));
    }

    /**
     * 删除失物招领、拼车服务、二手交易帖子
     */
    @PreAuthorize("@ss.hasPermi('posts:post:remove')")
    @Log(title = "失物招领、拼车服务、二手交易帖子", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(lblCsDiscussPostService.deleteLblCsDiscussPostByIds(ids));
    }
}
